package ce.com.cenewbluesdk.proxy;


import android.content.Context;

import ce.com.cenewbluesdk.CEBC;
import ce.com.cenewbluesdk.queue.CEProtocolB;
import ce.com.cenewbluesdk.uitl.Lg;
import ce.com.cenewbluesdk.bluetooth.CEBlueTooth_4;
import ce.com.cenewbluesdk.connect.ReconnectModeA;
import ce.com.cenewbluesdk.entity.CEDevData;
import ce.com.cenewbluesdk.entity.CESyncTime;
import ce.com.cenewbluesdk.queue.CEProtocolA;


/**
 * Created by Administrator on 2016/11/9 0009.
 */
public class CEDevK1Proxy extends CEBluetoothProxyBase {

    public static final String UUID = "0000cc03-0000-1000-8000-00805f9b34fb";

    public static final int devType = 1;

    SendHelper sendHelper = new SendHelper();


    protected CEDevK1Proxy(Context context) {
        super(context);
    }


    public SendHelper getSendHelper() {
        return sendHelper;
    }


    @Override
    protected void dataSendSucceed(CEDevData devData) {

        if (devData.getDataType() == CEBC.K1_DATA_TYPE_SYCN_TIME) {
            Lg.e("时间发送成功");
        }

    }

    @Override
    protected void DataSendFailed(CEDevData devData) {

    }

    @Override
    protected void receiptData(CEDevData devData) {

    }

    @Override
    protected void blueToothConnectStateChange(int state) {

        Lg.e("liu 连接状态改变 " + state);
        sendMeg(createMessage(CEBC.BLUE_CONNECT_STATE_CHANGE, state));

    }

    @Override
    protected void initProxy() {
        blueTooth = new CEBlueTooth_4(context, UUID);
        connectUtil = new CEConnectUtil(context, new ReconnectModeA(), this, blueTooth);
        devQueue = new CEDevQueue(this, new CEProtocolA(devType), blueTooth);
    }

    @Override
    protected String getClassName() {
        return "CEDevK1Proxy";
    }




    public class SendHelper {
        public void sendUserInfo() {
        }

        public void sendTime() {
            CESyncTime time = new CESyncTime();
            devQueue.push(time.toCEDevData());
        }

        public void getDevInfo() {
            CEDevData data = new CEDevData();
            data.setCmd(CEBC.CMD_REQUEST_TYPE);
            data.setDataType(CEBC.K1_DATA_TYPE_DEVINFO);
            devQueue.push(data);
        }

        public void getBattery() {
            CEDevData data = new CEDevData();
            data.setCmd(CEBC.CMD_REQUEST_TYPE);
            data.setDataType(CEBC.K1_DATA_TYPE_BATTERY_INFO);
            devQueue.push(data);
        }

    }


}
